Skip to content

Conversation

@klabacher
Copy link

Summary
This PR suppresses EAI_NODATA from getaddrinfo() during connection checks, which occurs for domains that only have A (IPv4) or AAAA (IPv6) records and is expected behavior for single-stack domains.

Instead of throwing (and spamming logs), the code returns an empty socket so the connection attempt is skipped for the missing address family while still allowing checks to proceed normally.

Context / Motivation
WSL may log CheckConnection: getaddrinfo() failed for domains that are IPv4-only or IPv6-only, even though networking continues to work.

This change avoids unnecessary error logs while keeping real failures intact (non-EAI_NODATA errors still throw).

Changes
Handle status == EAI_NODATA right after getaddrinfo() and return an empty socket (unique_socket) instead of throwing.

Change is isolated to src/shared/inc/conncheckshared.h.

Issues
Fixes #13937 and #13820.

Validation steps performed
Ran simple validation on an isolated x64 environment:
Started WSL and verified general connectivity works as expected (internet OK).
Verified IPv6 did not trigger the previous error condition (no IPv6-related error observed).
Confirmed the log spam does not occur after the change for single-stack scenarios.

This change prevents getaddrinfo() from throwing an error when a domain
only has A records (IPv4) or AAAA records (IPv6), which is expected
behavior for single-stack domains.

Fixes microsoft#13937 and microsoft#13820
Copilot AI review requested due to automatic review settings January 2, 2026 16:14
@klabacher klabacher requested a review from a team as a code owner January 2, 2026 16:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes unnecessary error logging when WSL performs connection checks on domains that only support IPv4 or IPv6. The change suppresses the EAI_NODATA error returned by getaddrinfo() when a domain lacks records for the requested address family (e.g., IPv4-only domains have no AAAA records), which is expected behavior and should not generate error logs.

Key Changes:

  • Added special handling for EAI_NODATA error code after getaddrinfo() calls
  • Returns an empty socket instead of throwing an exception when EAI_NODATA is encountered
  • Connection check continues normally for the available address family while skipping the unavailable one

@klabacher
Copy link
Author

@copilot open a new pull request to apply changes based on the comments in this thread

@klabacher
Copy link
Author

@microsoft-github-policy-service agree

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Collaborator

@OneBlue OneBlue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for doing this ! It's looking like the PR changes the line endings for this file, which makes its difficult to review, can you revert to the original line endings so we can review the change ?

@klabacher
Copy link
Author

FIxed CRLF formatting

@benhillis
Copy link
Member

FIxed CRLF formatting

I'm not sure you did, still showing a lot of changed whitespace in the file.

@klabacher
Copy link
Author

I'm sorry about this inconvenience. I will provide a proper fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unnecessary error: “getaddrinfo() failed: -5”

3 participants